#!/usr/bin/env node

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import chalk from 'chalk';
import inquirer from 'inquirer';
import { ConfigManager } from './config/configManager.js';
import SFTPClient from './sftp/sftpClient.js';
import { Logger } from './utils/logger.js';
import { mainMenu } from './menus/mainMenu.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

async function main() {
  try {
    Logger.banner();
    
    const configManager = new ConfigManager();
    const sftpClient = new SFTPClient();

    await mainMenu(sftpClient, configManager);
  } catch (error) {
    if (error.isTtyError) {
      Logger.error('提示: 当前环境不支持交互式 CLI');
    } else {
      Logger.error(`发生错误: ${error.message}`);
    }
    process.exit(1);
  }
}

main();
